<?php
  include("../includes.php");
  $membership = New Membership();
  $membership->confirm_admin();

  $agenda = new Agenda();
  $week   = $agenda->current_week;
  $jaar   = $agenda->year;
  $reserveringen = Reservering::by_week($week, $jaar);
  $aantal = count($reserveringen);
  include('../header.php');
?>

<div id='login'>

<h1>Reserveringen Week <?php echo $week; ?></h1>

<?php 
  for ($i = 0; $i < $aantal; $i++) : 
    $count  = 0; 
?>

<div class="block">
  <h2 class="red">
    <span><?php echo $reserveringen[$i]['dag']; ?></span>
    <?php echo Agenda::get_month_name_for_day($reserveringen[$i]['dag'], $week, $jaar); ?>
  </h2>
    
  <div id="info">  
    <table>
      <tr>
        <th>Tijd</th>
        <th>Voornaam</th>
        <th>Achternaam</th>
        <th>E-mail</th>
      </tr>

      <tr class="<?php echo ($count++ % 2 == 1) ? 'odd' : 'even' ?>">
        <td><?php echo $reserveringen[$i]['tijd']; ?></td>
        <td><?php echo $reserveringen[$i]['voornaam']; ?></td>
        <td><?php echo $reserveringen[$i]['achternaam']; ?></td>
        <td><?php echo $reserveringen[$i]['email']; ?></td>
      </tr>
  <?php 
    $temp_dag = $reserveringen[$i]['dag'];
    
    for ($j = $i+1; $j < $aantal; $j++) :
      if ($reserveringen[$j]['dag'] == $temp_dag) :
  ?>
        <tr class="<?php echo ($count++ % 2 == 1) ? 'odd' : 'even' ?>">
          <td><?php echo $reserveringen[$j]['tijd']; ?></td>
          <td><?php echo $reserveringen[$j]['voornaam']; ?></td>
          <td><?php echo $reserveringen[$j]['achternaam']; ?></td>
          <td><?php echo $reserveringen[$j]['email']; ?></td>
        </tr>
    <?php  
        $i = $j;  
      else :
        $i = $j-1;
        break;
      endif;
    endfor; ?>
    </table>
  </div>
</div>

<?php endfor; ?>
</div>
<?php include('../footer.php'); ?>